/**
 * 
 */
package com.fox.webapp.service.impl;

import javax.annotation.PostConstruct;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.fox.webapp.domain.Administrator;
import com.fox.webapp.persistent.AdministratorRepository;
import com.fox.webapp.service.IAdminService;

/**
 * @author yockii
 *
 */
@Service
public class AdminService implements IAdminService {
	private static final Logger logger = LoggerFactory.getLogger(AdminService.class);

	@Autowired
	private AdministratorRepository administratorRepository;
	
	@PostConstruct
	public void initAdminData(){
		Administrator a = new Administrator();
		a.setUsername("yockii");
		a.setPassword("1986327");
		administratorRepository.save(a);
	}
	
	@Override
	public boolean adminLogin(String username, String password) {
		return administratorRepository.findByUsernameAndPassword(username, password) != null;
	}
	
	
}
